import React, { useState } from 'react'
import { Modal,Button,Input,Form,InputNumber} from 'antd';
import http from '../../../../services/http'
import './add.css'

const { TextArea } = Input;



export default function Add() {
    const [visible, setVisible] = useState(false);
    const [data,setData] = useState({})

    const onFinish = (values) => {
        http({
            url:'/addlookreportpcuser',
            data:{
                user_name:values.user_name,
                DBP:values.DBP,
                SBP:values.SBP,
                BP:values.BP,
                health:values.health,
                hemameba:values.hemameba,
                red_blood:values.red_blood,
                hemoglobin:values.hemoglobin,
                HCT:values.HCT,
                opinionFirst:values.opinionFirst,
                ALT:values.ALT,
                AST:values.AST,
                GGT:values.GGT,
                opinionSecond:values.opinionSecond,
                pulse:values.pulse,
                indexa:values.indexa,
                conclusion:values.conclusion,
                order_orderId:values.order_orderId
            }
          }).then( (res) => {
            window.location.reload()
        })
    };
    
    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };

    return (
        <div>
            <Button type="primary" onClick={() => setVisible(true)}>
                添加
            </Button>
            <Modal
                className='data' 
                title="添加"
                centered
                footer={
                    [] // 设置footer为空，去掉 取消 确定默认按钮
                }
                onCancel={() => setVisible(false)}
                visible={visible}>
                    <Form  
                    name="basic"
                    labelCol={{ span: 8 }}
                    wrapperCol={{ span: 15 }}
                    initialValues={{ remember: true }}
                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                    >
                         <Form.Item
                            label="姓名"
                            name="user_name"
                            rules={[{required: true, message: '请输入姓名' }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="舒张压"
                            name="DBP"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="收缩压"
                            name="SBP"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="血小板"
                            name="BP"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="医疗保健"
                            name="health"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="白细胞"
                            name="hemameba"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="红细胞"
                            name="red_blood"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="血红蛋白"
                            name="hemoglobin"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="红细胞积压"
                            name="HCT"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="初步意见(血常规)"
                            name="opinionFirst"
                            rules={[{required: true, message: '初步意见' }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="丙氨酸基转氨酶"
                            name="ALT"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="AST/ALT"
                            name="AST"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="r-谷氨酰转氨酶"
                            name="GGT"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="初步意见(肝功能)"
                            name="opinionSecond"
                            rules={[{required: true, message: '初步意见' }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="脉搏"
                            name="pulse"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="指数"
                            name="indexa"
                            rules={[{
                                required: true, 
                                message: '请输入数字' ,
                                pattern: new RegExp(/^[1-9]\d*$/, "g")
                            }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="结论"
                            name="conclusion"
                            rules={[{required: true, message: '初步结论' }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="订单号"
                            name="order_orderId"
                            rules={[{required: true, message: '初步结论' }]}
                            >
                            <Input />
                        </Form.Item>
                        <Form.Item wrapperCol={{ offset: 11, span: 16 }}>
                            <Button onClick={() => setVisible(false)}>
                            取消
                            </Button>

                            <Button type="primary" htmlType="submit" style={{margin:'10px'}} onClick={() => setVisible(false)}>
                            提交
                            </Button>
                        </Form.Item>
                    </Form>
            </Modal>
        </div>
    )
}